package com.tarena.lbs.basic.web.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tarena.lbs.basic.web.mapper.UserGroupMapper;
import com.tarena.lbs.common.security.utils.LbsSecurityContenxt;
import com.tarena.lbs.pojo.basic.po.UserGroupPO;
import com.tarena.lbs.pojo.basic.query.UserGroupQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class UserGroupRepository {
    @Autowired
    private UserGroupMapper userGroupMapper;
    public PageInfo<UserGroupPO> getUserGroupsByPage(Integer businessId) {
        QueryWrapper<UserGroupPO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("business_id", businessId);
        PageHelper.startPage(1,10);
        return PageInfo.of(userGroupMapper.selectList(queryWrapper));
    }

    public void saveAdmin(UserGroupPO poParam) {
        userGroupMapper.insert(poParam);
    }

    public UserGroupPO getUserGroup(Integer userGroupId) {
        return userGroupMapper.selectById(userGroupId);
    }
}
